package com.example.myui.model;

import android.content.Context;
import android.os.Environment;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.AppGlideModule;

/**
 * Created by Administrator on 2018/2/24/024.
 */
@GlideModule
public class GlideCache extends AppGlideModule {
    private String appRootPath =null;
    private String sdRootPath  = Environment.getExternalStorageDirectory().getPath();;

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        int diskCacheSizeBytes = 1024 * 1024 * 100; // 100 MB
        //手机app路径
        appRootPath = context.getCacheDir().getPath();
        builder.setDiskCache(new DiskLruCacheFactory( Environment.getExternalStorageDirectory()+"/aGlideDisk", diskCacheSizeBytes ));

        super.applyOptions(context, builder);
    }


    @Override
    public void registerComponents(Context context, Glide glide, Registry registry) {
        super.registerComponents(context, glide, registry);
    }
}
